﻿using System.Globalization;
using System.Web.Mvc;

namespace TSharp.Core.Mvc.Web.Filters
{
    /// <summary>
    ///     <para>2010/10/26</para>
    ///     <para>TANGJINGBO</para>
    ///     <author>tangjingbo</author>
    /// </summary>
    public class CultureActionFilterAttribute : ActionFilterAttribute
    {
        /// <summary>
        ///     在执行操作方法之前由 MVC 框架调用。
        /// </summary>
        /// <param name="filterContext">筛选器上下文。</param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            CultureInfo ci = AopContext.GetDefaultLactor().Get<ISiteProvider>().GetCurrentCultureInfo();
            SiteProvider.SetThreadCulture(ci);
            base.OnActionExecuting(filterContext);
        }
    }
}